Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix location of MacroExpression nodes #15524

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Sija
Copy link
Contributor

@Sija Sija commented Feb 25, 2025

Fixes incorrect location of MacroExpression nodes, due to the fact that:

  1. @token.location was being called too late, since parse_macro_expression was advancing the position before the assignment
  2. and OTOH token_end_location was being called too early

Before this PR:

node         # => {{ type }}
location     # => src/random.cr:320:45
end_location # => src/random.cr:320:45

source_between(location, end_location) # => "}"

after:

node         # => {{ type }}
location     # => src/random.cr:320:39
end_location # => src/random.cr:320:46

source_between(location, end_location) # => "{{type}}"

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:parser labels Feb 25, 2025
@ysbaddaden ysbaddaden added this to the 1.16.0 milestone Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants